<?php
include('dbconnect.php');
$cli_id = (isset($_GET['cli_id']))? $_GET['cli_id'] : $cli_id;
$con_id = (isset($con_id))? $con_id: -1;
$con_id = (isset($_GET['con_id']))? $_GET['con_id'] : $con_id;
$num_participant = (isset($_GET['num_participant']))? $_GET['num_participant'] : $num_participant;
?>
<div id='participant<?=$num_participant?>'>
	<select name='client<?=$num_participant?>' id='client<?=$num_participant?>' onchange='UpdateContacts(<?=$num_participant?>)'>	
<?php
$sql = 'SELECT cli_id, cli_nom FROM clients ORDER BY cli_nom';
if ($result=$db->query($sql)){
	$nb = $result->num_rows;
	for ($j = 0; $j < $nb; $j++){
		$row = $result->fetch_assoc();
?>
	<option value='<?=$row['cli_id']?>' <?=($row['cli_id']==$cli_id)? "selected='selected'":''?>><?=htmlspecialchars($row['cli_nom'])?></option>
<?php	
	}
}
$result->free();
?>
	</select>
	<select name='contact<?=$num_participant?>' id='contact<?=$num_participant?>'>
<?php
$sql = "SELECT con_id, con_nom FROM contacts WHERE con_cli_id='$cli_id' ORDER BY con_nom";
if ($result=$db->query($sql, False)){
	$nb = $result->num_rows;
	$retour= Array();
	for ($j = 0; $j < $nb; $j++){
		$row = $result->fetch_assoc();
?>
	<option value='<?=$row['con_id']?>' <?=($row['con_id']==$con_id)? "selected='selected'":''?>><?=htmlspecialchars($row['con_nom'])?></option>
<?php	
	}
}
$result->free();
?>
	</select>
	<a href='JavaScript:AjoutContact(<?=$num_participant?>)'>Ajouter un contact</a>
<?php
if ($num_participant!=0){
?>
	<a href='JavaScript:SupprParticipant(<?=$num_participant?>)'>Enlever ce participant</a>
<?php
}
?>
</div>

<script language="JavaScript" type="text/javascript">
	dernier = dernier+1;
</script>

